<template>
	<view class="content">
		<view class="title">真实姓名</view>
		<input placeholder="请输入真实姓名" placeholder-class="placeholder" v-model="realName" maxlength="5" type="text" />
		<view class="title">账号</view>
		<input placeholder="请输入支付宝账号" placeholder-class="placeholder" v-model="alipayAccount" maxlength="25" />
		<view class="sure" @tap="add">保存</view>
	</view>
</template>

<script>
	// import { editPayment,paymentDetail } from '../../api/api.js'
	export default {
		data() {
			return {
				// 真实姓名
				realName:'',
				// 支付宝账号
				alipayAccount:'',
				// 收款方式id
				id:'',
			}
		},
		onLoad(e) {
			this.id = e.id
			if(this.id) {
				// 获取收款方式详情
				this.getDetail()
			}
		},
		methods: {
			// 获取收款方式详情
			getDetail() {
				let data = {
					id:this.id
				}
				paymentDetail(data).then( res=> {
					this.realName = res.data.realName
					this.alipayAccount = res.data.alipayAccount
				})
			},
			add() {
				let data = {
					id:this.id,
					realName:this.realName,
					alipayAccount:this.alipayAccount,
					paymentTermType:0,
				}
				editPayment(data).then( res=> {
					console.log(res)
					uni.showToast({
						icon:'none',
						title:'添加成功~'
					})
				  setTimeout(function() {
						uni.navigateBack({
							delta:2
						})
					},1000)
				})
			}
		}
	}
</script>

<style lang="less">
  .content {
		.title {
			margin: 40rpx 0 0 30rpx;
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #000000;
			line-height: 40rpx;
		}
		.placeholder {
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #999999;
			line-height: 40rpx;
		}
		input {
			width: 690rpx;
			margin: 10rpx 0 0 30rpx;
			height: 90rpx;
			border-bottom: 2rpx solid #F2F2F2;
		}
		.sure {
			margin-left: 30rpx;
			position: fixed;
			bottom:191rpx ;
			text-align: center;
			line-height: 90rpx;
			width: 690rpx;
			height: 90rpx;
			background: #FE3B33;
			border-radius: 45rpx;
			font-size: 28rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
		}
	}
</style>
